package com.liuxinlong.modules.common.service.impl;

import com.liuxinlong.enums.AssetsCategoryTypeEnum;
import com.liuxinlong.enums.AssetsProjectTypeEnum;
import com.liuxinlong.enums.BarPointBusinessEnum;
import com.liuxinlong.enums.BarPointSourceEnum;
import com.liuxinlong.enums.ButlerBusinessTypeEnum;
import com.liuxinlong.enums.ButlerExpertTypeEnum;
import com.liuxinlong.enums.ButlerExternalTypeEnum;
import com.liuxinlong.enums.ButlerFaqTypeEnum;
import com.liuxinlong.enums.ButlerGpsTypeEnum;
import com.liuxinlong.enums.ButlerHotTypeEnum;
import com.liuxinlong.enums.ButlerPatentTypeEnum;
import com.liuxinlong.enums.ButlerProcessTypeEnum;
import com.liuxinlong.enums.ButlerProductTypeEnum;
import com.liuxinlong.enums.ConvolutionStatusTypeEnum;
import com.liuxinlong.enums.DealOperateEnum;
import com.liuxinlong.enums.EcnChangeTypeEnum;
import com.liuxinlong.enums.ExpertGroupEnum;
import com.liuxinlong.enums.FileBusinessTypeEnum;
import com.liuxinlong.enums.InvestmentExpensesEnum;
import com.liuxinlong.enums.InvestmentLossRateEnum;
import com.liuxinlong.enums.InvestmentTurnoverEnum;
import com.liuxinlong.enums.MessageContentTypeEnum;
import com.liuxinlong.enums.MessagePushBusinessEnum;
import com.liuxinlong.enums.ProjectStageEnum;
import com.liuxinlong.enums.QuestionStatusEnum;
import com.liuxinlong.enums.RedisKeyEnum;
import com.liuxinlong.enums.RegionEnum;
import com.liuxinlong.enums.WorkflowTypeEnum;
import com.liuxinlong.modules.common.entity.CommonSelectDto;
import com.liuxinlong.modules.common.service.CommonSelectService;
import com.liuxinlong.modules.dao.AssetsBudgetDao;
import com.liuxinlong.modules.dao.AssetsDepartmentDao;
import com.liuxinlong.modules.dao.BarLuckDao;
import com.liuxinlong.modules.dao.BarPlateDao;
import com.liuxinlong.modules.dao.BarPresentDao;
import com.liuxinlong.modules.dao.ButlerTrainDao;
import com.liuxinlong.modules.dao.ClassificationDao;
import com.liuxinlong.modules.dao.DepartmentDao;
import com.liuxinlong.modules.dao.ExpertDao;
import com.liuxinlong.modules.dao.FileManageDao;
import com.liuxinlong.modules.dao.PatentDepartmentDao;
import com.liuxinlong.modules.dao.PatentProductClassDao;
import com.liuxinlong.modules.dao.PatentRiskDao;
import com.liuxinlong.modules.dao.ProjectDao;
import com.liuxinlong.modules.dao.RoleDao;
import com.liuxinlong.modules.dao.StandardDao;
import com.liuxinlong.modules.dao.UserDao;
import com.liuxinlong.modules.dao.UserGroupDao;
import com.liuxinlong.modules.dao.UserLevelDao;
import com.liuxinlong.modules.dao.UserPostDao;
import com.liuxinlong.modules.dao.UserTeamDao;
import com.liuxinlong.modules.dao.WorkFlowConfigDao;
import com.liuxinlong.modules.dao.WorkFlowGroupDao;
import com.liuxinlong.modules.entity.AssetsBudget;
import com.liuxinlong.modules.entity.AssetsDepartment;
import com.liuxinlong.modules.entity.BarLuck;
import com.liuxinlong.modules.entity.BarPlate;
import com.liuxinlong.modules.entity.BarPresent;
import com.liuxinlong.modules.entity.ButlerTrain;
import com.liuxinlong.modules.entity.Classification;
import com.liuxinlong.modules.entity.Expert;
import com.liuxinlong.modules.entity.PatentDepartment;
import com.liuxinlong.modules.entity.PatentProductClass;
import com.liuxinlong.modules.entity.PatentRisk;
import com.liuxinlong.modules.entity.Project;
import com.liuxinlong.modules.entity.Standard;
import com.liuxinlong.modules.entity.User;
import com.liuxinlong.modules.entity.UserDepartment;
import com.liuxinlong.modules.entity.UserGroup;
import com.liuxinlong.modules.entity.UserLevel;
import com.liuxinlong.modules.entity.UserPost;
import com.liuxinlong.modules.entity.UserRole;
import com.liuxinlong.modules.entity.UserTeam;
import com.liuxinlong.modules.entity.WorkFlowConfig;
import com.liuxinlong.modules.entity.WorkFlowGroup;
import com.liuxinlong.modules.patent.service.PatentService;
import com.liuxinlong.modules.sync.service.SyncService;
import com.liuxinlong.utils.IPUtils;
import com.liuxinlong.utils.ObjectUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 通用下拉选项数据接口实现
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2022-01-14
 */
@Service
@Slf4j
public class CommonSelectServiceImpl implements CommonSelectService {
    @Autowired
    private DepartmentDao departmentDao;

    @Autowired
    private UserDao userDao;

    @Autowired
    private RoleDao roleDao;

    @Autowired
    private UserPostDao postDao;

    @Autowired
    private UserLevelDao userLevelDao;

    @Autowired
    private UserTeamDao teamDao;

    @Autowired
    private StandardDao standardDao;

    @Autowired
    private ClassificationDao classificationDao;

    @Autowired
    private BarPlateDao barPlateDao;

    @Autowired
    private UserGroupDao userGroupDao;

    @Autowired
    private SyncService syncService;

    @Autowired
    private ButlerTrainDao butlerTrainDao;

    @Autowired
    private ExpertDao expertDao;

    @Autowired
    private FileManageDao fileManageDao;

    @Autowired
    private BarLuckDao barLuckDao;

    @Autowired
    private BarPresentDao barPresentDao;

    @Autowired
    private PatentDepartmentDao patentDepartmentDao;

    @Autowired
    private PatentProductClassDao patentProductClassDao;

    @Autowired
    private PatentService patentService;

    @Autowired
    private AssetsBudgetDao assetsBudgetDao;

    @Autowired
    private AssetsDepartmentDao assetsDepartmentDao;

    @Autowired
    private ProjectDao projectDao;

    @Autowired
    private PatentRiskDao patentRiskDao;

    @Autowired
    private WorkFlowGroupDao workFlowGroupDao;

    @Autowired
    private WorkFlowConfigDao workFlowConfigDao;

    @Override
    public List<CommonSelectDto> queryDepartmentSelect() {
        List<UserDepartment> originList = departmentDao.getDepartmentList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserDepartment department : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(department.getId());
            dto.setLabel(department.getName());
            dto.setValue(department.getId());
            dto.setName(department.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryUserSelect() {
        List<User> originList = userDao.getUserList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (User user : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(user.getId());
            dto.setLabel(user.getName());
            dto.setValue(user.getId());
            dto.setName(user.getName());
            dto.setParam1(user.getSn());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryRoleSelect() {
        List<UserRole> originList = roleDao.getRoleList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserRole role : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(role.getId());
            dto.setLabel(role.getName());
            dto.setValue(role.getId());
            dto.setName(role.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPostSelect() {
        List<UserPost> originList = postDao.getUserPostList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserPost post : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(post.getId());
            dto.setLabel(post.getName());
            dto.setValue(post.getId());
            dto.setName(post.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryUserLevelSelect() {
        List<UserLevel> originList = userLevelDao.getUserLevelList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserLevel userLevel : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(userLevel.getId());
            dto.setLabel(userLevel.getName());
            dto.setValue(userLevel.getId());
            dto.setName(userLevel.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryTeamSelect() {
        List<UserTeam> originList = teamDao.getTeamList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserTeam userTeam : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(userTeam.getId());
            dto.setLabel(userTeam.getName());
            dto.setValue(userTeam.getId());
            dto.setName(userTeam.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryDesignStandardSelect() {
        List<Standard> originList = standardDao.getStandardList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (Standard standard : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(standard.getId());
            dto.setLabel(standard.getStandardSn());
            dto.setValue(standard.getId());
            dto.setName(standard.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryParentClassificationSelect() {
        List<Classification> originList = classificationDao.getParentClassificationList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (Classification item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryDealTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (DealOperateEnum item : DealOperateEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryQuestionStatusSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (QuestionStatusEnum item : QuestionStatusEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryBarPlateSelect() {
        List<BarPlate> originList = barPlateDao.getShowPlate();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (BarPlate item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryUserGroupSelect() {
        List<UserGroup> originList = userGroupDao.queryUserGroupList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (UserGroup item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryFileBusinessSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (FileBusinessTypeEnum item : FileBusinessTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryMaterialSelect(String keyword, String region) {
        String realRegion = StringUtils.equals(region, RegionEnum.WSCNJ.getName()) ? RegionEnum.WPCNJ.getName() : region;
        List<Map<String, String>> originList = syncService.asyncQuerySiteMaterial(keyword, realRegion);
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (Map<String, String> item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.get("pt_part"));
            dto.setLabel(item.containsKey("ptp_site") ? RegionEnum.getNameByValue(item.get("ptp_site")) : item.get("pt_domain"));
            dto.setValue(item.get("pt_part"));
            dto.setName(item.get("pt_desc1"));
            dto.setParam1(item.get("ptp_site"));
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> querySubClassificationList(String id) {
        List<Classification> originList = classificationDao.getSubClassificationList(id);
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (Classification item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryTrainSelect() {
        List<ButlerTrain> originList = butlerTrainDao.queryAllTrainList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (ButlerTrain item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getTitle());
            dto.setValue(item.getId());
            dto.setParam1(ButlerBusinessTypeEnum.getNameByValue(item.getBusinessType() + 2));
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryTrainBusinessSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ButlerBusinessTypeEnum item : ButlerBusinessTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryExpertSubSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ButlerExpertTypeEnum item : ButlerExpertTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryMessageSourceSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (MessagePushBusinessEnum item : MessagePushBusinessEnum.values()) {
            if (item.getValue() > 99) {
                continue;
            }
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            dto.setParam1(item.getMsgTile());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPatentSubSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ButlerPatentTypeEnum item : ButlerPatentTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPointsBusinessSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (BarPointBusinessEnum item : BarPointBusinessEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPointsSourceSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (BarPointSourceEnum item : BarPointSourceEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryTrainSubSelect(String business) {
        int bus = Integer.parseInt(business);
        List<CommonSelectDto> resultList = new ArrayList<>();
        if (bus == 1) {
            for (ButlerFaqTypeEnum item : ButlerFaqTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 2) {
            for (ButlerProcessTypeEnum item : ButlerProcessTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 3) {
            for (ButlerProductTypeEnum item : ButlerProductTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 4) {
            for (ButlerProductTypeEnum item : ButlerProductTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 5) {
            for (ButlerExternalTypeEnum item : ButlerExternalTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 6) {
            for (ButlerExpertTypeEnum item : ButlerExpertTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 7) {
            for (ButlerPatentTypeEnum item : ButlerPatentTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 8) {
            for (ButlerGpsTypeEnum item : ButlerGpsTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        } else if (bus == 9) {
            for (ButlerHotTypeEnum item : ButlerHotTypeEnum.values()) {
                CommonSelectDto dto = new CommonSelectDto();
                dto.setId(String.valueOf(item.getValue()));
                dto.setLabel(item.getName());
                dto.setValue(String.valueOf(item.getValue()));
                dto.setName(item.getName());
                resultList.add(dto);
            }
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryMessageContentSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (MessageContentTypeEnum item : MessageContentTypeEnum.values()) {
            if (
//                    item.getValue() == MessageContentTypeEnum.TEXT.getValue() ||
                    item.getValue() == MessageContentTypeEnum.VOICE.getValue() ||
                            item.getValue() == MessageContentTypeEnum.VIDEO.getValue() ||
                            item.getValue() == MessageContentTypeEnum.FILE.getValue() ||
                            item.getValue() == MessageContentTypeEnum.IMAGE_TEXT.getValue() ||
                            item.getValue() == MessageContentTypeEnum.MARK_DOWN.getValue() ||
                            item.getValue() == MessageContentTypeEnum.MINI_PROGRAM_NOTICE.getValue() ||
                            item.getValue() == MessageContentTypeEnum.TEMPLATE_CARD.getValue()) {
                continue;
            }
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryExpertGroupSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ExpertGroupEnum item : ExpertGroupEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryExpertSelect(String type) {
        List<Expert> originList = expertDao.queryExpertList(StringUtils.isEmpty(type) ? 0 : Integer.parseInt(type));
        String currentIp = IPUtils.getCurrentIp();
        Set<String> fileIdSet = originList.stream().map(Expert::getPicture).collect(Collectors.toSet());
        Map<String, Map<String, Object>> fileMap = new HashMap<>();
        if (!fileIdSet.isEmpty()) {
            fileMap = fileManageDao.getFileMapByIds(fileIdSet);
        }
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (Expert item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            Map<String, Object> fileInfo = fileMap.get(item.getPicture());
            dto.setParam1(ObjectUtils.isEmpty(fileInfo) ? "" :
                    String.valueOf(fileInfo.get("path")).replace("upload", "http:\\\\" + currentIp + ":8090\\preview\\upload"));
            dto.setParam2(item.getArea());
            dto.setParam3(item.getBrief());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryRedisSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (RedisKeyEnum item : RedisKeyEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryConvolutionStatusSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ConvolutionStatusTypeEnum item : ConvolutionStatusTypeEnum.values()) {
            if (item.getValue() == 8) {
                continue;
            }
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryBarLuckSelect(int status) {
        Map<String,Object> queryPram = new HashMap<>();
        queryPram.put("startNum",0);
        queryPram.put("pageSize",10000);
        queryPram.put("status",status);
        List<BarLuck> originList = barLuckDao.pageBarLuckList(queryPram);
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (BarLuck item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getTitle());
            dto.setValue(item.getId());
            dto.setName(item.getTitle());
            dto.setParam1(item.getSn());
            dto.setParam2(item.getStatus() == 0 ? "未生效" : "已生效");
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryBarPresentSelect(int status) {
        Map<String,Object> queryPram = new HashMap<>();
        queryPram.put("startNum",0);
        queryPram.put("pageSize",10000);
        queryPram.put("status",status);
        List<BarPresent> originList = barPresentDao.pageBarPresentList(queryPram);
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (BarPresent item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            dto.setParam1(item.getSn());
            dto.setParam2(item.getStatus() == 0 ? "不可用" : "可用");
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPatentDepSelect() {
        Map<String,Object> queryPram = new HashMap<>();
        queryPram.put("startNum",0);
        queryPram.put("pageSize",10000);
        List<String> depList = patentService.getUserDepartment();
        if (depList.isEmpty()) {
            return new ArrayList<>();
        }
        queryPram.put("depList",depList);
        List<PatentDepartment> originList = patentDepartmentDao.pageDepartmentList(queryPram);
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (PatentDepartment item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            dto.setParam1(item.getSn());
            dto.setParam2(item.getManage());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPatentProductSelect() {
        List<PatentProductClass> originList = patentProductClassDao.getProductClassList();
        List<CommonSelectDto> resultList = new ArrayList<>(originList.size());
        for (PatentProductClass item : originList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getName());
            dto.setValue(item.getId());
            dto.setName(item.getName());
            dto.setParam1(String.valueOf(item.getDefaultShow()));
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryAssetsProjectTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (AssetsProjectTypeEnum item : AssetsProjectTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryAssetsTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (AssetsCategoryTypeEnum item : AssetsCategoryTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryAssetsBudgetSelect() {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("startNum",0);
        queryParam.put("pageSize",1000);
        List<AssetsBudget> assetsBudgetList = assetsBudgetDao.pageAssetsBudget(queryParam);
        List<CommonSelectDto> resultList = new ArrayList<>(assetsBudgetList.size());
        for (AssetsBudget item : assetsBudgetList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getPlanNo());
            dto.setValue(item.getId());
            dto.setName(item.getProjectName());
            dto.setParam1(String.valueOf(item.getLeftAmount()));
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryAssetsDepartmentSelect() {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("startNum",0);
        queryParam.put("pageSize",1000);
        List<AssetsDepartment> assetsDepartmentList = assetsDepartmentDao.pageAssetsDepartmentInfo(queryParam);
        Map<String,Map<String,String>> departmentMap = patentDepartmentDao.getDepartmentMap();
        List<CommonSelectDto> resultList = new ArrayList<>(assetsDepartmentList.size());
        for (AssetsDepartment item : assetsDepartmentList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getDepartment());
            dto.setLabel(departmentMap.get(item.getDepartment()).get("name"));
            dto.setValue(item.getDepartment());
            dto.setName(departmentMap.get(item.getDepartment()).get("name"));
            dto.setParam1(String.valueOf(item.getDepartmentSn()));
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryEcnChangeTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (EcnChangeTypeEnum item : EcnChangeTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryProjectSelect() {
        List<Project> projectList = projectDao.getAvailableProject();
        List<CommonSelectDto> resultList = new ArrayList<>(projectList.size());
        for (Project item : projectList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getProjectName());
            dto.setValue(item.getId());
            dto.setName(item.getProjectName());
            dto.setParam1(item.getProjectSn());
            dto.setParam2(item.getProjectFinancialSn());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryPatentRiskSelect(String id) {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("pageSize",10000);
        queryParam.put("status",1);
        queryParam.put("startNum",0);
        queryParam.put("projectId",id);
        List<PatentRisk> riskList = patentRiskDao.pagePatentRiskList(queryParam);
        List<CommonSelectDto> resultList = new ArrayList<>(riskList.size());
        for (PatentRisk item : riskList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getRiskName());
            dto.setValue(item.getId());
            dto.setName(item.getRiskName());
            dto.setParam1(item.getReferenceModel());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryWorkflowTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (WorkflowTypeEnum item : WorkflowTypeEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryWorkflowGroupSelect() {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("startNum",0);
        queryParam.put("pageSize",10000);
        List<WorkFlowGroup> riskList = workFlowGroupDao.pageWorkflowGroupList(queryParam);
        List<CommonSelectDto> resultList = new ArrayList<>(riskList.size());
        for (WorkFlowGroup item : riskList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getGroupName());
            dto.setValue(item.getId());
            dto.setName(item.getGroupName());
            dto.setParam1(item.getGroupSn());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryProjectStageSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (ProjectStageEnum item : ProjectStageEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryWorkflowConfigSelect() {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("startNum",0);
        queryParam.put("pageSize",10000);
        List<WorkFlowConfig> riskList = workFlowConfigDao.pageWorkflowConfigList(queryParam);
        List<CommonSelectDto> resultList = new ArrayList<>(riskList.size());
        for (WorkFlowConfig item : riskList) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(item.getId());
            dto.setLabel(item.getFlowName());
            dto.setValue(item.getId());
            dto.setName(item.getFlowName());
            dto.setParam1(item.getStatus() == 1 ? "启用" : "未启用");
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryInvestmentExpensesTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (InvestmentExpensesEnum item : InvestmentExpensesEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryInvestmentLossRateTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (InvestmentLossRateEnum item : InvestmentLossRateEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public List<CommonSelectDto> queryInvestmentTurnoverTypeSelect() {
        List<CommonSelectDto> resultList = new ArrayList<>();
        for (InvestmentTurnoverEnum item : InvestmentTurnoverEnum.values()) {
            CommonSelectDto dto = new CommonSelectDto();
            dto.setId(String.valueOf(item.getValue()));
            dto.setLabel(item.getName());
            dto.setValue(String.valueOf(item.getValue()));
            dto.setName(item.getName());
            resultList.add(dto);
        }
        return resultList;
    }
}
